# TS平台我的组员明细数据比邻有惠老带新

import unittest
from time import sleep

from Common.base_test import BaseTestClass
from PageObjects.login.login_page import LoginPage
from PageObjects.TS.ts_my_team_member_page import TsMyTeamMemberPage
from TestDatas.login_datas import ts_user_data
from TestDatas.CommDatas import web_login_url

from Common.BeautifulReport import BeautifulReport
from Common.dir_config import *


class TsMyTeamDetail(BaseTestClass):
    """TS我的组员明细数据"""
    def test_0_1_go_to_ar_question_bank_management(self):
        """OA登录并跳转TS"""
        self.driver.get(web_login_url)
        self.lp = LoginPage(self.driver)
        # 步骤：登录页面-登录操作
        self.lp.login(ts_user_data["user"], ts_user_data["pwd"])
        sleep(3)
        self.assertTrue(self.lp.assert_welcome())
        self.lp.go_ts()
        self.lp.switch_window("教学服务平台")
        sleep(10)

    def test_0_2_my_team_detail_lst(self):
        """我的组员明细数据-比邻有惠-列表"""
        self.tp = TsMyTeamMemberPage(self.driver)
        self.tp.close_alert()  # 处理alert弹窗
        self.tp.go_my_team_nav()  # 点击导航栏我的组员-明细数据

    def test_0_3_old_with_new(self):
        """比邻有惠老带新商机数据"""
        self.tp = TsMyTeamMemberPage(self.driver)
        self.tp.go_old_with_new()  # 头部tab滑动至比邻有惠老带新
        self.tp.search_old_with_new()  # 搜索老带新数据
        bus_data = self.tp.business_result()  # 获取合计商机明细数据
        self.assertIn("田1137", bus_data, "明细数据不存在期望数据，请检查")


if __name__ == '__main__':
    # unittest.main()
    suite = unittest.TestSuite()
    suite.addTests(unittest.makeSuite(TsMyTeamDetail))
    result = BeautifulReport(suite)
    result.report(filename="TS我的组员明细数据", description='TS我的组员明细数据', log_path=htmlreport_dir)

